import pandas as pd
import numpy as np

def find_season_dates(data_path='weather.csv'):
    # 读取数据
    df = pd.read_csv(data_path)
   
    # 准备数据
    dates = pd.to_datetime(df['Date'])
    temps = df['Temperature(Celsius)(avg)'].values
    
    # 计算5天滑动平均，至少需要5个有效值
    sliding_avg = pd.Series(temps).rolling(window=5, min_periods=5).mean().values
    
    # 初始化季节转换日期
    season_dates = {
        '入春': None,
        '入夏': None,
        '入秋': None,
        '入冬': None
    }
    
    # 辅助函数：在滑动平均达标窗口中找第一个达标的日气温
    def find_first_in_window(sliding_idx, temp_threshold, condition):
        window_start = max(0, sliding_idx - 4)
        window_end = sliding_idx + 1
        window_dates = dates[window_start:window_end]
        window_temps = temps[window_start:window_end]
        
        if condition == '>=':
            day_indices = np.where(window_temps >= temp_threshold)[0]
        else:
            day_indices = np.where(window_temps < temp_threshold)[0]
        
        if len(day_indices) > 0:
            return window_dates.iloc[day_indices[0]]
        return None
    
    # 1. 找入春日期 (滑动平均≥10℃后的第一个日平均≥10℃)
    spring_sliding_indices = np.where(sliding_avg >= 10)[0]
    if len(spring_sliding_indices) > 0:
        for idx in spring_sliding_indices:
            spring_date = find_first_in_window(idx, 10, '>=')
            if spring_date:
                season_dates['入春'] = spring_date
                break
    
    # 2. 找入夏日期 (滑动平均≥22℃后的第一个日平均≥22℃)
    summer_sliding_indices = np.where(sliding_avg >= 22)[0]
    if len(summer_sliding_indices) > 0:
        for idx in summer_sliding_indices:
            summer_date = find_first_in_window(idx, 22, '>=')
            if summer_date:
                season_dates['入夏'] = summer_date
                break
    
    # 3. 找入秋日期 (滑动平均<22℃后的第一个日平均<22℃)
    if season_dates['入夏']:
       summer_idx = dates[dates == season_dates['入夏']].index[0]
       # 从入夏后第6天开始找(确保是新的滑动窗口)
       search_start = summer_idx + 5
       autumn_sliding_indices = np.where(sliding_avg[search_start:] < 22)[0] + search_start
        
       for idx in autumn_sliding_indices:
           autumn_date = find_first_in_window(idx, 22, '<')
           if autumn_date:
               season_dates['入秋'] = autumn_date
               break  

    # 4. 找入冬日期 (滑动平均<10℃后的第一个日平均<10℃)
    winter_sliding_indices = np.where(sliding_avg < 10)[0]
    if len(winter_sliding_indices) > 0:
        # 从入秋之后开始找
        if season_dates['入秋']:
            autumn_idx = dates[dates == season_dates['入秋']].index[0]
            winter_sliding_indices = winter_sliding_indices[winter_sliding_indices > autumn_idx]
            
            for idx in winter_sliding_indices:
                winter_date = find_first_in_window(idx, 10, '<')
                if winter_date:
                    season_dates['入冬'] = winter_date
                    break
    
    return season_dates

def determine_season(input_date, data_path='weather.csv'):
    # 获取季节转换日期
    season_dates = find_season_dates(data_path)
    
    # 处理输入日期
    try:
        input_dt = pd.to_datetime(input_date)
    except:
        return "无效的日期格式"
    
    # 确定季节
    if season_dates['入夏'] and input_dt >= season_dates['入夏']:
        if season_dates['入秋'] and input_dt >= season_dates['入秋']:
            if season_dates['入冬'] and input_dt >= season_dates['入冬']:
                return '冬季'
            else:
                return '秋季'
        else:
            return '夏季'
    elif season_dates['入春'] and input_dt >= season_dates['入春']:
        return '春季'
    else:
        return '冬季'


# 测试示例
if __name__ == "__main__":
    test_date = input()
    season = determine_season(test_date)
    print(season)